package main

import (
	"fmt"
	"gitee.com/li-haowei/rxgo"
)

func main() {
	var res = []int{0, 10, 20, 30, 40, 10, 30}
	fmt.Printf("The test data is : %v\n", res)

	//Debounce
	res = []int{}
	rxgo.Just(0, 10, 20, 30, 40, 10, 30).Debounce(10000).Subscribe(func(x int) {
		res = append(res, x)
	})
	fmt.Printf("The result of Debounce is : %v\n", res)

	//Distinct
	res = []int{}
	rxgo.Just(0, 10, 20, 30, 40, 10, 30).Distinct().Subscribe(func(x int) {
		res = append(res, x)
	})
	fmt.Printf("The result of Distinct is : %v\n", res)

	//ElementAt
	res = []int{}
	rxgo.Just(0, 10, 20, 30, 40, 10, 30).ElementAt(3).Subscribe(func(x int) {
		res = append(res, x)
	})
	fmt.Printf("The result of ElementAt is : %v\n", res)

	//First
	res = []int{}
	rxgo.Just(0, 10, 20, 30, 40, 10, 30).First().Subscribe(func(x int) {
		res = append(res, x)
	})
	fmt.Printf("The result of First is : %v\n", res)

	//IgnoreElements
	res = []int{}
	rxgo.Just(0, 10, 20, 30, 40, 10, 30).IgnoreElements().Subscribe(func(x int) {
		res = append(res, x)
	})
	fmt.Printf("The result of IgnoreElements is : %v\n", res)

	//Last
	res = []int{}
	rxgo.Just(0, 10, 20, 30, 40, 10, 30).Last().Subscribe(func(x int) {
		res = append(res, x)
	})
	fmt.Printf("The result of Last is : %v\n", res)

	//Skip
	res = []int{}
	rxgo.Just(0, 10, 20, 30, 40, 10, 30).Skip(3).Subscribe(func(x int) {
		res = append(res, x)
	})
	fmt.Printf("The result of Skip is : %v\n", res)

	//SkipLast
	res = []int{}
	rxgo.Just(0, 10, 20, 30, 40, 10, 30).SkipLast(4).Subscribe(func(x int) {
		res = append(res, x)
	})
	fmt.Printf("The result of SkipLast is : %v\n", res)

	//Take
	res = []int{}
	rxgo.Just(0, 10, 20, 30, 40, 10, 30).Take(2).Subscribe(func(x int) {
		res = append(res, x)
	})
	fmt.Printf("The result of Take is : %v\n", res)

	//TakeLast
	res = []int{}
	rxgo.Just(0, 10, 20, 30, 40, 10, 30).TakeLast(3).Subscribe(func(x int) {
		res = append(res, x)
	})
	fmt.Printf("The result of TakeLast is : %v\n", res)
}
